package com.kaishengit.web;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.kaishengit.entity.Contact;
import com.kaishengit.service.ContactService;
import com.kaishengit.util.web.ServletUtil;

public class ContactEdit extends HttpServlet {

	private static final long serialVersionUID = 1L;

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
		String id = request.getParameter("id");
		
		Contact ct = new ContactService().findById(id);
		
		request.setAttribute("id",id);
		ServletUtil.forword(request, response,"contact/contact_edit");
		
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String id = request.getParameter("id");
		String name = request.getParameter("name");
		String companyname = request.getParameter("companyname");
		String tel = request.getParameter("tel");
		String mobile = request.getParameter("moible");
		String address = request.getParameter("address");
		String mail = request.getParameter("mail");
		String index = request.getParameter("index");
		String weibo = request.getParameter("weibo");
		String content = request.getParameter("content");
		String projectid = request.getParameter("projectid");
		
		Contact ct = new Contact();
		
		ct.setName(name);
		ct.setCompanyname(companyname);
		ct.setAddress(address);
		ct.setContent(content);
		ct.setIndex(index);
		ct.setTel(tel);
		ct.setMobile(mobile);
		ct.setMail(mail);
		ct.setProjectid(projectid);
		ct.setWeibo(weibo);
		
		
		new ContactService().findById(id);
		
		ServletUtil.forword(request, response, "contact/contact.jspx");

	}

}
